package com.ruoyi.purchase.service.impl;

import com.ruoyi.purchase.domain.QualityInfo;
import com.ruoyi.purchase.mapper.QualityInfoMapper;
import com.ruoyi.purchase.service.IQualityInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * qualityInfoService业务层处理
 * 
 * @author kevinness
 * @date 2025-01-15
 */
@Service
public class QualityInfoService implements IQualityInfoService
{
    @Autowired
    private QualityInfoMapper qualityInfoMapper;

    /**
     * 查询qualityInfo
     *
     * @param inspectionNo qualityInfo主键
     * @return qualityInfo
     */
    @Override
    public QualityInfo selectQualityInfoByInspectionNo(String inspectionNo)
    {
        return qualityInfoMapper.selectQualityInfoByInspectionNo(inspectionNo);
    }

    /**
     * 查询qualityInfo列表
     *
     * @param qualityInfo qualityInfo
     * @return qualityInfo
     */
    @Override
    public List<QualityInfo> selectQualityInfoList(QualityInfo qualityInfo)
    {
        return qualityInfoMapper.selectQualityInfoList(qualityInfo);
    }

    /**
     * 新增qualityInfo
     *
     * @param qualityInfo qualityInfo
     * @return 结果
     */
    @Override
    public int insertQualityInfo(QualityInfo qualityInfo)
    {
        return qualityInfoMapper.insertQualityInfo(qualityInfo);
    }

    /**
     * 修改qualityInfo
     *
     * @param qualityInfo qualityInfo
     * @return 结果
     */
    @Override
    public int updateQualityInfo(QualityInfo qualityInfo)
    {
        QualityInfo info = qualityInfoMapper.selectQualityInfoByInspectionNo(qualityInfo.getInspectionNo());
        if(info != null){
            return qualityInfoMapper.updateQualityInfo(qualityInfo);
        }
        else{
            return qualityInfoMapper.insertQualityInfo(qualityInfo);
        }
    }

    /**
     * 批量删除qualityInfo
     *
     * @param inspectionNos 需要删除的qualityInfo主键
     * @return 结果
     */
    @Override
    public int deleteQualityInfoByInspectionNos(String[] inspectionNos)
    {
        return qualityInfoMapper.deleteQualityInfoByInspectionNos(inspectionNos);
    }

    /**
     * 删除qualityInfo信息
     *
     * @param inspectionNo qualityInfo主键
     * @return 结果
     */
    @Override
    public int deleteQualityInfoByInspectionNo(String inspectionNo)
    {
        return qualityInfoMapper.deleteQualityInfoByInspectionNo(inspectionNo);
    }
}
